#include "Common.h"
void SafeCopyWCHAR(wchar_t** dest, const wchar_t* source)
{
	SafeDeleteArray(*dest);
	size_t length = wcslen(source);
	*dest = new wchar_t[length+1];
	wcscpy(*dest, source);
	(*dest)[length] = 0;
}
void SafeCopyCHAR(char** dest, const char* source)
{
	SafeDeleteArray(*dest);
	size_t length = strlen(source);
	*dest = new char[length+1];
	strcpy(*dest, source);
	(*dest)[length] = 0;
}
void SafeAppendCHAR(char** dest, const char* source)
{
	size_t length = strlen(*dest) + strlen(source);
	char* temp = new char[length+1];
	strcpy(temp, *dest);
	strcat(temp, source);
	temp[length] = 0;
	SafeDeleteArray(*dest);
	*dest = temp;
}
void SafeMergeCHAR(char** dest, const char* source1, const char* source2)
{
	SafeDeleteArray(*dest);
	size_t length = strlen(source1) + strlen(source2);
	*dest = new char[length+1];
	strcpy(*dest, source1);
	strcat(*dest, source2);
	(*dest)[length] = 0;
}
void ConvertCharToWchar(wchar_t* dest, const char* source)
{
	int len = strlen(source);
	mbstowcs(dest, source, len);
	dest[len] = 0;
}